package dao

import (
	"WORKSPACE/models"
	"fmt"
)

func GetAlldepartment() (error, []models.Department, int64) {
	var DepartmentData []models.Department
	//AttendanceData := []models.Attendance{{"1qwe",1,"1",1,1,1,1,1,}}
	var total int64
	fmt.Println(DepartmentData)
	err := db.Table("department").Order("Dno ASC").Count(&total).Find(&DepartmentData).Error
	fmt.Println(DepartmentData)
	return err, DepartmentData, total
}

func Adddepartment(department models.Department) error {
	err := db.Table("department").Create(&department).Error
	return err
}

func Updatedepartment(department models.Department) error {
	err := db.Table("department").Where("Dno = ?", department.Dno).Updates(department).Error
	return err
}

func Deldepartment(dno string) error {
	err := db.Table("department").Where("Dno = ? ", dno).Delete(models.Attendance{}).Error
	return err
}